<%@ page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<%@ include file="/app/include.jsp"%>  
		<script src='<%=basePath%>common/uploadify/jquery.uploadify.files.js'></script>
		<script>
			var haveFile = 0;
			$(document).ready(function() {
			  $('#file_upload').uploadify({ 
			    'buttonClass' : 'butto', //按钮样式
			    'swf' : '<%=basePath%>common/uploadify/script/uploadify.swf', 
			    'buttonText'    :   '请选择数据文件', 
			    'uploader'  : '<%=basePath %>datamanage/saveOneImage.do',
			    'method': "get",
			    'queueID'   : 'fileQueue',
			    'auto'      : false,
			    'debug': false,//debug模式开/关，打开后会显示debug时的信息   
			    'multi'     : false,
			  	'fileTypeExts'        : '*.gif;*.jpg;*.png',
			  	onSelect : function(file){
			  		haveFile = 1;
			    }, 
			    onCancel : function(file){ //removeCompleted ：true模式下  删除不反应，是个BUG; 根据需求进行修复
			    	haveFile = 0;
			    },
			    onUploadSuccess: function (file,data,response) {
			    	haveFile = 0;
			    	$("#filename").text("已上传文件： " + file.name);
			    	$("#id").val(data);
			    	//window.opener.location.replace('<%=basePath%>datamanage/loadImageList.do');
			    	alert("保存成功！");
			    },
			    onUploadError : function(file,errorcode,errormsg,errorstring){
			    	alert(" 上传错误！ ");
			    }
			  });
			});
			
			// 开始上传
			function beginUpload(formData){ 
			    if(haveFile == 0){ // 无文件触发确定
			    	formData.haveFile = 0;
			    	$.ajax({
						type: "POST",
						url: '<%=basePath %>datamanage/saveOneImage.do',
						dataType : 'text',
						data: formData,
						success: function(data){
							$("#id").val(data);
							alert("保存成功！");
						},
						error: function(data){
							alert("出错了");
						}
					}); 
			    }else{
     			 	$('#file_upload').uploadify('settings','formData',formData);
			 		$('#file_upload').uploadify('upload','*');
			    }
			 }
 		</script>
	</head>
	<body style="overflow-x:hidden;">
	<div class="cotnent">
    	<br/>
    	<div id="uploader_message"></div>
        <form id="modelForm" name="modelForm">
        <input type="hidden" id="id" name="id" value="${imageobj.id}"/>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <th width="15%"><span class="red">*</span> 名称</th>
                <td><input type="text" name="namestr" id="namestr" value="${imageobj.namestr}" style="width:70%"/></td> 
              </tr>
               <tr>
                <th>分组</th>
                <td >
                	 <input type="text" name="groupname" id="groupname" value="${mdobj.groupname}" style="width:70%"/>
                </td> 
              </tr> 
              <tr> 
                <th width="15%"><span class="red">*</span> 关键词</th>
                <td>
                <input type="text" name="keyword" id="keyword" value="${imageobj.keyword}" style="width:70%"/>
                 </td>
              </tr>
              <tr>
                <th>类别</th>
                <td > 
                	  <open:select valueset="[图片类别]" id="imagetype" name="imagetype" width="80%" selectedValue="${mdobj.imagetype}"/> 
                </td> 
              </tr>
              <tr>
               <th>备注</th>
                <td>
                     <textarea name="memo" id="memo" rows="5" cols="75%">${mdobj.memo}</textarea>  
                </td>
              </tr> 
          </table>
          </form> 
          <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td id="filename" width="30%">
                </td>
                <td>
	                <div id="fileQueue" align="center"> 
		               <input id="file_upload" name="file_upload" type="file" multiple="true"/>	&nbsp;&nbsp;
	            	</div> 
                </td>
              </tr>
          </table>
         </div> 
	</body>
</html>
		

